package com.inmaytide.website.mapper.system;

import com.inmaytide.website.domain.entities.system.SysPermission;
import com.inmaytide.website.mapper.system.provider.SysPermissionMapperSQLProvider;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.SelectProvider;
import tk.mybatis.mapper.common.Mapper;

import java.util.Collection;
import java.util.List;

public interface SysPermissionMapper extends Mapper<SysPermission> {

    @SelectProvider(method = "findPermissionCodesByRoleCodes", type = SysPermissionMapperSQLProvider.class)
    @Results({
            @Result(column = "permission_name", property = "permissionName"),
            @Result(column = "permission_code", property = "permissionCode"),
            @Result(column = "permission_desc", property = "permissionDesc"),
            @Result(column = "permission_type", property = "permissionType"),
            @Result(column = "permission_parent", property = "permissionParent")
    })
    public List<SysPermission> findPermissionCodesByRoleCodes(@Param("roleCodes") Collection<String> roleCodes);
}